﻿using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using System.Text;

namespace ToDoListReminder.Data
{
	/// <summary>
	/// Contains the project data.
	/// </summary>
	[DataContract]
	public class Project : BaseDataObject
	{
		#region Fields

		/// <summary>
		/// Holds the file name.
		/// </summary>
		private string fileName_;

		/// <summary>
		/// Holds the file name saved.
		/// </summary>
		private string fileNameSaved_;
		#endregion

		#region Properties

		/// <summary>
		/// Gets or sets the file name (full path).
		/// </summary>
		[DataMember]
		public string FileName
		{
			get
			{
				return fileName_;
			}

			set
			{
				fileName_ = value;
				SetPropertyChanged("FileName");
			}
		}
		#endregion

		#region Constructors

		/// <summary>
		/// Initializes a new instance of the Project class.
		/// </summary>
		/// <param name="fileName"></param>
		public Project(string fileName)
		{
			FileName = fileName;
		}

		#endregion

		#region Overrides

		/// <summary>
		/// Gets the text representation of the instance.
		/// </summary>
		/// <returns>The text representation of the instance.</returns>
		public override string ToString()
		{
			var buffer = new StringBuilder("Project:");

			buffer.AppendFormat(" FileName: \"{0}\"", FileName);

			return buffer.ToString();
		}
		#endregion

		/// <summary>
		/// Saves the data members.
		/// </summary>
		protected override void Save()
		{
			fileNameSaved_ = FileName;
	}

		/// <summary>
		/// Restores the data members.
		/// </summary>
		protected override void Restore()
		{
			FileName = fileNameSaved_;
		}
	}
}
